<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE HTML>
<%-- <%@include file="edit.jsp"%> --%>
<html>
<head>
<script type="text/javascript">

	$(function() {
		$('#enabled').radiobox({name:'entity.enabled',value:true,data:[[true,'有效'],[false,'无效']]});
		$('#iUserType').combobox({
		    data:$codelist('userType'),editable:false,width:180
		});
		$('#toolbar').toolbar({buttons:[
			{name:'save',iconCls:'icon-save',text:'保存'}
	  	],handler:handler});
	});
	function handler() {
		switch(this.name) {
			case 'save': toSave();break;
		}
	}
	function toSave(){
		$.messager.progress({title:'系统提示',text:'数据处理中，请耐心等待...'});
		$.submit('#dataform',function(r) {
			$.messager.progress('close');
			if(r.code<0) return $alert(r.msg);
			top.$prompt('保存成功');
			top.$window.close(window,1,null);
		});
	}
	function toDeploy(){
		showUpload({title:'上传封面'
			,options:{
				filters:{
					mime_types: [{title : "封面图片", extensions : "jpg,png"}]
				},
				multi_selection: false ,
				 init:{
					 FileUploaded:function(uploader,file,responseObject){
						 var response = responseObject.response;
						 var json = eval('(' + response + ')');
						 var data = json.data;
						 var path = data.fileUrl;
						 $("#imgurl").val(path);
						 showImg(path);
					 }
				},
				complete:function(){
					top.$ok('上传成功');
				}
			}
		});
	}
	function showImg(path){
		$("#img_show").attr("src",path);
	}
	
</script>
</head>
<body>
	<div id="toolbar" class="toolbar" ></div>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center',border:false">
			<form id="dataform" action="edit" method="post">
				<input type="hidden" name="entity.enabled" value="${item.enabled }">
				<input type="hidden" name="entity.id" value="${item.id }">
				<table cellpadding="5" style="width:100%;">
					<tr>
						<td style="width:20%;">广告标题:</td>
						<td style="width:80%;">
							<input class="easyui-textbox" name="entity.title" value="${item.title }" data-options="required:true"/>
						</td>
					</tr>
					<tr>
						<td>广告类型:</td>
						<td>
							<select class="easyui-combobox" name="entity.type" value="${item.type}" id="comb_tagType" data-options="required:true,panelHeight:'auto' ">
								<option value="1">栏目 </option>
								<option value="3">发布内容 </option>
							</select>
						</td>
					</tr>
					<tr>
						<td>开始时间:</td>
						<td>
							<input class="easyui-datetimebox" name="entity.startDt" value="<f:formatDate value="${item.startDt}" pattern="yyyy-MM-dd HH:mm:ss"/>">
						</td>
					</tr>
					<tr>
						<td>结束时间:</td>
						<td>
							<input  class="easyui-datetimebox" name="entity.endDt" value="<f:formatDate value="${item.endDt}" pattern="yyyy-MM-dd HH:mm:ss"/>">
						</td>
					</tr>
					<tr>
						<td>广告链接:</td>
						<td>
							<input class="easyui-textbox" name="entity.link" value="${item.link }" data-options="editable:false" />
						</td>
					</tr>
					<tr>
						<td>广告图片:</td>
						<td>
							<input type="button" value="修改" onclick="toDeploy()">
						</td>
					</tr>
					<tr>
						<td></td>
						<td>
							<input id="imgurl" name="entity.imgurl" type="hidden" value="${item.imgurl}">
							<img id="img_show" alt="广告图片" src="${item.imgurl}" style="width: 80px;height: 80px;">
						</td>
					</tr>
					<tr>
						<td>广告描述:</td>
						<td>
							<input class="easyui-textbox" name="entity.description" value="${item.description }" data-options="multiline:true" style="height:100px;width:100%;"/>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</body>
</html>